/*
 * Created on 26.07.2004
 *
 * Copyright (c) 2004 The GnutellaSim Project
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 2 as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
package util;

import java.util.Random;

/**
 * @author bennobaumgartner
 *
 * TODO Comment
 */
public class GaussianNumberGenerator implements NumberGenerator {
	
	private int mean;
	private int deviation;
	private Random rng;

	public GaussianNumberGenerator(int mean,int deviation) {
		this.mean = mean;
		this.deviation = deviation;
		rng = new Random();
	}

	/* (non-Javadoc)
	 * @see util.NumberGenerator#getNumber()
	 */
	public int getNumber() {

		int n = (int)Math.round(rng.nextGaussian()*deviation+mean);
		if (n<0) {
			return 0;
		} else {
			return n;
		}
	}

}
